<?php
/*****************
* wondershare产品类模板接口类
*创建日期:2012-4-24
*作者：tjx
******************/
include(dirname(__FILE__).'/../public/public_products.php');

class WondershareProducts  extends PublicProducts {
	
	var $db, $web_fage;
	function __construct($arr = NULL) {
		$this->db = $GLOBALS['db'];
		$this->web_fage = 1;
		parent::__construct($this->db, $this->web_fage);
	}
	
	/**
	* 返回feature功能点
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function keyFeature($get) {
		
			$str = '';
			$id = (int) $get['产品ID'];
			
			$sql = "SELECT f.feature_title,f.feature_intro,f.feature_pic_min,f.feature_pic_max ,f.feature_id 
					FROM feature f 
					LEFT JOIN won_product won_p ON f.product_id = won_p.won_product_id 
					WHERE f.feature_type = 0 AND f.is_delete = 0 AND won_p.id = {$id}
					ORDER BY f.feature_order ASC ";
			$row = $this->db->getAll($sql);
			
			foreach ( $row as $key => $values ) {
				
				$pic_str = '';
				$feature_title = trim($values['feature_title']);
				if (!empty($feature_title)) {
					$feature_title = '<h3>'.$values['feature_title'].'</h3>';
				}
				
				if (!empty($values['feature_pic_min'])) {
					if (!empty($values['feature_pic_max'])) {
						$pic_str = '<a href="'.$values['feature_pic_max'].'" class="zoom1" title="'.
									$values['feature_title'].'"><img src="'.$values['feature_pic_min'].'" width="275" height="160" /></a>' ;
					} else {
						$pic_str = '<img src="'.$values['feature_pic_min'].'" alt="'.$values['feature_title'].'" />';
					}
					
					$str .= $feature_title .' <div class="text"> <dl>'.$values['feature_intro'].'</dl></div><div class="pic">'.
							$pic_str.'</div>';
				}else
				{  
					$str .= $feature_title.$values['feature_intro'];
				}
			
			
			}
			unset($row);
			return  $str;
		
		
	}
	
	/**
	* 返回下载与免费上
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function downloadAndPriceTop($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$sql = "SELECT p.product_isfree ,p.product_id,p.product_brand,p.product_name, p.product_type,won_p.giveaway,won_p.getcodeurl 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE won_p.id = {$id} AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);
		
		$version = get_sale_version($row['product_id']);
		
		$download_jump_url = $version['download_url'];
	
		
		
		if ($row['product_brand'] == 'Wondershare') {
			$brand_type = "WS/";
		} elseif ($row['product_brand'] == 'iSkysoft') {
			$brand_type = "IS/";
		}
		
		$product_name = trim(str_replace($row['product_brand'], '', $row['product_name']));
		$click_url = "var that=this;_gaq.push(['_trackEvent', this.href, 'Download', document.location.pathname]); _gaq.push(['_trackPageview', this.href]); setTimeout(function(){location.href=that.href;},100);return false;";
		
		$sql = "SELECT url 
					FROM Table_39 
					WHERE Field_20326 = '{$row['product_id']}' ";
		$buy_url = $this->db->getOne($sql);
		
		if (empty($buy_url))
		{
			$sql = "SELECT url 
						FROM Table_74 
						WHERE Field_20734 = '{$row['product_id']}' ";
			$buy_url = $this->db->getOne($sql);
		}
		
		$buy_url = url_replace($get['url'], $buy_url, 'buy_url');
		
		if ($id == 39) {
			$buy_url = 'http://store.wondershare.com.br/shop/buy/buy-mac-pdf-editor-pro.html';
		}
		
		if ($row['product_isfree'] == 1) {
			$str = '<a href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url.'" class="download2">Free Download</a>';
		} else {
		
			if ($row['product_type'] == 1) {
				$str = '<a href="'.$download_jump_url.'" rel="nofollow" target="_blank" onClick="'.$click_url.'" class="try fl">Baixar</a>';
			}
			$str .= '<a href="'.$buy_url.'" class="buy fr">Comprar</a>';
		}
		
		if ($row['giveaway'] == 1) {
			$str = '<a href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url.'" class="download2 fl">Baixar</a>';
		}
		return $str;
	}
	
	/**
	* 返回下载与免费中
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function downloadAndPriceMid($get) {
		
		$id = (int) $get['产品ID'];
		$str = $old_price = $year_str = $new_price = '';
		
		$sql = "SELECT p.product_isfree ,p.product_id, p.product_type,p.product_brand,p.product_name,p.product_version ,p.product_is_year_charge,won_p.giveaway,won_p.getcodeurl 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE won_p.id = {$id}  AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);
		
		if ($row['product_brand'] == 'Wondershare') {
			$brand_type = "WS/";
		} elseif ($row['product_brand'] == 'iSkysoft') {
			$brand_type = "IS/";
		}
		
		$product_name = trim(str_replace($row['product_brand'], '', $row['product_name']));
		$price_arr = get_price($row['product_id']);
// 		print_r($price_arr);Array ( [curr] => 129,90 [old] => ) 
		
		$new_price = $price_arr['curr'];
		
		$version = get_sale_version($row['product_id']);
		$row['product_version'] = $version['version_name'];
		
		$download_jump_url = $version['download_url'];
		
		
		
		$sql = "SELECT url FROM Table_39 WHERE Field_20326 = '{$row['product_id']}'";
		$buy_url = $this->db->getOne($sql);
		if (empty($buy_url)) {
			$sql = "SELECT url FROM Table_74 WHERE Field_20734 = '{$row['product_id']}' ";
			$buy_url = $this->db->getOne($sql);
		}
		$buy_url = url_replace($get['url'], $buy_url, 'buy_url');
		
		if ($id == 39)
		{
			$buy_url = 'http://store.wondershare.com.br/shop/buy/buy-mac-pdf-editor-pro.html';
		}
		
		if (isset($price_arr['unique'])) {
			$old_price = 'R$'.$price_arr['old'];
		}
		
		if ($row['product_is_year_charge']) {
			$year_str = '/year';
		}
		
		$ver_count = count(explode('.', $row['product_version'])); 
		
		if ($ver_count > 3) {
			$product_version = substr($row['product_version'], 0, strrpos($row['product_version'], '.'));
		} else {
			$product_version  = $row['product_version'];
		}
		
		$click_url = "var that=this;_gaq.push(['_trackEvent', this.href, 'Download', document.location.pathname]); _gaq.push(['_trackPageview', this.href]); setTimeout(function(){location.href=that.href;},100);return false;";
		
		if ($row['product_isfree'] == 1) {
			$str = '<a  href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url.'"  class="download fl" >
					<span class="dd">Versão: '.$product_version.'</span><span class="security"><img height="18" width="25" src="http://images.wondershare.com.br/style/images0328/pro_06.png">Download seguro</span></a>';
		} else {
		
			if ($row['product_type'] == 1) {
				$str = '<a href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url.'"  class="free fl">
				<span class="dd">Versão: '.$product_version.'</span><span class="security"><img height="18" width="25" src="http://images.wondershare.com.br/style/images0328/pro_06.png">Download seguro</span></a>';
			}
			
			if ($row['giveaway'] == 1) {
				$new_price = str_replace('.', ',', $new_price) ;
				$str .= '<a href="'.$row['getcodeurl'].'" class="getfree fr" onclick="'.$click_url.'"><span class="dd"><span style="text-decoration:line-through" >R$'.$new_price.$year_str.'</span> Free</span></a>';
			} else {
				$old_price = str_replace('.', ',', $old_price) ;
				$new_price = str_replace(',', '.', $new_price) ;
				$new_price = $new_price / 6.00 ;
// 				echo $new_price;	//12.483333333333	21.65

				$new_price_arr = explode('.', $new_price) ;
				if($new_price_arr[1] > 100 )
					$new_price = $new_price + 0.01 ;
				$new_price = $new_price . '0' ;  ///避免相加末尾为0
				$new_price = substr($new_price, 0 , strpos($new_price, '.') + 3 );
// 				$temp_price = $new_price ;
// 				$new_price = substr($new_price, 0 , strpos($new_price, '.') + 3 );
// 				if($temp_price > $new_price)
// 					$new_price = $new_price + 0.01 ;
				$new_price = str_replace('.', ',', $new_price) ;
				$str .= '<a href="'.$buy_url.'" class="buy2 fl"><span class="dd"><span style="text-decoration:line-through" >'.$old_price.'</span> Apenas 6x R$ '.$new_price.$year_str.'</span><span class="security"><img height="18" width="25" src="http://images.wondershare.com.br/style/images0328/pro_08.png">90 dias de garantia de devolução</span></a>';
			}
		}
		unset($row);
		return  $str;
	}
	
	/**
	* 返回下载与免费下
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function downloadAndPriceBtn($get) {
		
		$str = $old_price = $new_price = $year_str = '';
		$id = (int) $get['产品ID'];

		$sql = "SELECT p.product_isfree ,p.product_id, p.product_type,p.product_brand,p.product_name,p.product_version , p.product_is_year_charge,won_p.giveaway,won_p.getcodeurl 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE won_p.id = {$id} AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);

		if ($row['product_brand'] == 'Wondershare') {
			$brand_type = "WS/";
		} elseif ($row['product_brand'] == 'iSkysoft') {
			$brand_type = "IS/";
		}
		$product_name = trim(str_replace($row['product_brand'], '', $row['product_name']));
		
		$price_arr = get_price($row['product_id']);
		$new_price = $price_arr['curr'];
		
		$version = get_sale_version($row['product_id']);
		$row['product_version'] = $version['version_name'];
		
		$download_jump_url = $version['download_url'];
		
		
		$sql = "SELECT url FROM Table_39 WHERE Field_20326 = '{$row['product_id']}'";
		$buy_url = $this->db->getOne($sql);
		
		if (empty($buy_url)) {
			
			$sql = "SELECT url FROM Table_74 WHERE Field_20734 = '{$row['product_id']}' ";
			$buy_url = $this->db->getOne($sql);
		}
		
		$buy_url = url_replace($get['url'],$buy_url ,'buy_url');
		if ($id == 39) {
			$buy_url = 'http://store.wondershare.com.br/shop/buy/buy-mac-pdf-editor-pro.html';
		}
		
		if (isset($price_arr['unique'])) {
			$old_price = 'R$'.$price_arr['old'];
		}
		if ($row['product_is_year_charge']) {
			$year_str = '/year';
		}
		
		$ver_count = count(explode('.', $row['product_version'])); 
		$product_version = $ver_count > 3 ? substr($row['product_version'], 0, strrpos($row['product_version'], '.')) :  $row['product_version'];
		
		$click_url = "var that=this;_gaq.push(['_trackEvent', this.href, 'Download', document.location.pathname]); _gaq.push(['_trackPageview', this.href]); setTimeout(function(){location.href=that.href;},100);return false;";
		
		if ($row['product_isfree'] == 1) {
			$str = '<a href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url .'"  class="download fl">
					<span class="dd">Versão: '.$product_version.'</span></a>';
		} else {
		
			if ($row['product_type'] == 1) {
				$str = '<a href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url .'"  class="free fl">
						<span class="dd">Versão: '.$product_version.'</span></a>';
			}
			if ($row['giveaway'] == 1) {
				$new_price = str_replace('.', ',', $new_price) ;
				$str .= '<a href="'.$row['getcodeurl'].'" class="getfree fr" onclick="'.
						$click_url .'"><span class="dd"><span style="text-decoration:line-through" >R$'.
						$new_price.$year_str.'</span> Free</span></a>';
			} else {
				$old_price = str_replace('.', ',', $old_price) ;
				$new_price = str_replace(',', '.', $new_price) ;
				$new_price = $new_price / 6.00 ;
				
				$temp_price = $new_price ;
				$new_price = substr($new_price, 0 , strpos($new_price, '.') + 3 );
				if($temp_price > $new_price)
					$new_price = $new_price + 0.01 ;
				$new_price = str_replace('.', ',', $new_price) ;
				$str .= '<a href="'.$buy_url.'" class="buy2 fr"><span class="dd"><span style="text-decoration:line-through" >'.
						$old_price.'</span> Apenas 6x R$ '.$new_price.$year_str.'</span></a>';
			}
		}
		unset($row);
		return  $str;
	}
	

	/**
	* 返回产品买点
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productBuySome($get) {
		
		$id = (int) $get['产品ID'];
		$sql = "SELECT p.product_key_feature 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0  ";

		$product_key_feature = $this->db->getOne($sql);
		
		return empty($product_key_feature) ? '' : $product_key_feature;
	
		
	}
	
	/**
	* 返回页面当前地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function currentUrl($get) {
		
		return str_replace('/wondershare.com.br/httpdocs/', 'http://www.wondershare.com.br/', $get['url']);

	}
	
	/**
	* 返回产品广告语
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productAdLanguage($get) {
		
		$id = (int) $get['产品ID'];
		$sql = "SELECT p.product_ad 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0  ";
		$product_ad = $this->db->getOne($sql);
		
		return empty($product_ad) ? '' : $product_ad;
	}
	
	/**
	* 返回feature更多功能点
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function moreFeature($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT f.feature_title,f.feature_intro,f.more_feature_pic 
				FROM feature f 
				LEFT JOIN won_product won_p ON f.product_id = won_p.won_product_id 
				WHERE f.feature_type = 1 AND f.is_delete = 0 AND won_p.id = {$id} AND won_p.won_product_delete = 0 
				ORDER BY f.feature_order ASC ";
		$result = $this->db->query($sql);
		
		$sum = 0;
		while ($row = $this->db->fetch_array($result)) {
			if ($sum == 0) {
				$str .= '<h3>Mais recursos</h3>';
			}
			$str .= ' <div class="k"><h4>'.$row['feature_title'].'</h4><img src="'.$row['more_feature_pic'].
					'" alt="'.$row['feature_title'].'" width="43" height="43" /><p>'.
					$row['feature_intro'].'</p> <div class="clear"></div></div>';
					
			if (($sum + 1) % 3 == 0) {
				$str.= '<div class="clear"></div>';
			}
			
			$sum = $sum + 1;
		}
		unset($row);
		return  $str;
		
	}
	
	/**
	* 返回关联产品
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function relProduct($get) {
		
		
		$str = '';
		$id = (int) $get['产品ID'];

		$recommended_product = $this->db->getOne("SELECT recommended_product FROM won_product WHERE id = {$id}");
		
		$click_url = "var that=this;_gaq.push(['_trackEvent', this.href, 'Download', document.location.pathname]); _gaq.push(['_trackPageview', this.href]); 
					setTimeout(function(){location.href=that.href;},100);return false;";
		
		if (!empty($recommended_product)) {
			$sql = "SELECT * 
					FROM ( 
					    SELECT art . * 
					    FROM (
					        SELECT tab.url,p.product_name,p.product_isfree,p.product_type,p.product_brand,p.product_intro,won_p.id,product_id,p.product_box_middle, p.product_is_year_charge 
					        FROM Table_26 tab 
					        LEFT JOIN won_product won_p ON tab.Field_20044 = won_p.id 
					        LEFT JOIN product p ON won_p.won_product_id = p.product_id 
					        WHERE won_p.won_product_delete = 0 AND FIND_IN_SET(won_p.id,'{$recommended_product}') ) art 
					    UNION
					    SELECT art . * 
					    FROM ( 
					        SELECT tab.url,p.product_name,p.product_isfree,p.product_type,p.product_brand,p.product_intro,won_p.id,product_id,p.product_box_middle,p.product_is_year_charge 
					        FROM Table_45 tab 
					        LEFT JOIN won_product won_p ON tab.Field_20350 = won_p.id 
					        LEFT JOIN product p ON won_p.won_product_id = p.product_id 
					        WHERE won_p.won_product_delete = 0 AND tab.Field_20361 = 1 AND FIND_IN_SET(won_p.id,'{$recommended_product}') ) art 
					)  artlist LIMIT 3 ";
			$result = $this->db->query($sql);
			
			$sum = 0;	
			while ($row = $this->db->fetch_array($result)) {
				
				$year_str = $old = $brand_type = '';
				
				$price_arr = get_price($row['product_id']);
				
				$new = empty($price_arr['curr']) ? '' : 'R$'.$price_arr['curr'];
				if (isset($price_arr['unique']) && !empty($price_arr['old'])) {
					$old = 'R$'.$price_arr['old'];
				}
				
				if ($row['product_is_year_charge']) {
					$year_str = '/year';
				}
				
				if ($row['product_brand'] == 'Wondershare') {
					$brand_type = "WS/";
				} else if ($row['product_brand'] == 'iSkysoft') {
					$brand_type = "IS/";
				}
				
				$version = get_sale_version($row['product_id']);
				
				$get['产品ID'] = $row['id'];
				
				$download_jump_url = $version['download_url'];
				
				
				
				$sql = 'SELECT url FROM Table_39 WHERE Field_20326 = '.$row['product_id'];
				$buy_url = $this->db->getOne($sql);
				
				if (empty($buy_url)) {
					$sql = 'SELECT url FROM Table_74 WHERE Field_20734 = '.$row['product_id'];
					$buy_url = $this->db->getOne($sql);
				}
				
				$buy_url = empty($buy_url)? '' : url_replace($get['url'], $buy_url, 'buy_url');
				
				if ($id == 39) {
					$buy_url = 'http://store.wondershare.com.br/shop/buy/buy-mac-pdf-editor-pro.html';
				}
				
				$row['url'] = str_replace("/wondershare.com.br/httpdocs", 'http://www.wondershare.com.br', $row['url']);
				$product_name = trim(str_replace($row['product_brand'], '', $row['product_name']));
				$product_name = str_replace('(português)', '', $product_name) ;
				$old = str_replace('.', ',', $old) ;
				$new = str_replace('.', ',', $new) ;
				$str .='<div class="box"> <div class="fl"> 
						<a href="'.$row['url'].'"><img src="'.$row['product_box_middle'].'" alt="'.$product_name.'" /></a>
						<p class="price"><del >'.$old.'</del> '.$new.$year_str.'  </p></div>
						<div class="info"> <span>'.$row['product_brand'].'</span>
						<h4><a href="'. $row['url'].'">'.$product_name.'</a></h4>
						<p>'.$row['product_intro'].'</p>
						<div class="btn">';
				
				$try = '' ;
				$buy = '' ;
				if (!empty($download_jump_url)) {
					if ($row['product_isfree'] == 1) {
						$str .='<a href="'.$download_jump_url.'" onclick="'.$click_url.'" charset="try">'.$try.'</a>';
					} else {
					
						if ($row['product_type'] == 1) {
							$str .='<a href="'.$download_jump_url.'" onclick="'.$click_url.'" charset="try">'.$try.'</a>';
						}
					
					}
				}
				
				if(!empty($buy_url)) {
					$str .= '<a href="'.$buy_url.'" class="buy">'.$buy.'</a>'; 
				}
				$str .= '</div></div></div>';
			}
		}
		$get['产品ID'] = $id;
		return $str;
		
	}
	
	/**
	* 返回右侧bar
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightBar($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT won_product_guide_bar  FROM won_product WHERE id = {$id} ";
		$bar = $this->db->getOne($sql);
		if (!empty($bar)) {
			$sql_block = "SELECT block_title,block_content,block_pic_url ,block_pic  FROM block  WHERE FIND_IN_SET(block_id,'".$bar."') AND block_delete = 0";
			$result = $this->db->query($sql_block);
			
			while ($row = $this->db->fetch_array($result)) {
				$str_image = '';
				if ($row['block_pic']) {
					$str_image = ' <p class="pic"><a href="'.$row['block_pic_url'].'"><img src="'.$row['block_pic'].'" /></a></p>';
				}
				$str .= '<div class="side_box210"><h4>'.$row['block_title'].'</h4>'.$str_image.'        <p class="dd">'.
						$row['block_content'].'</p><p class="ar"><a href="'.$row['block_pic_url'].'">Mais Detalhes>></a></p></div>';
			
			}
		}
		$str .= '<input type="hidden" id="products_id" name="products_id" value="'.$id.'" />';
		
		return  $str;
		
	}
	
	
	/**
	* 返回右侧视频bar
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightVideoBar($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];

		$sql = "SELECT p.product_video_promo,p.product_brand,p.product_name 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);
		
		if (empty($row['product_video_promo'])) {
			return  '';
		}
		
		$str = '<div class="side_box210">
				<div class="pic videoDemo" href="#video-demo">
				<img src="http://images.wondershare.com.br/style/images0328/video_bg2.png" width="158" height="126" alt="'.
				$row['product_name'].'" /></div><div class="video videoDemo" href="#video-demo">Watch the Video Demo</div> </div>';
		unset($row);	
		return  $str;
		
	}
	
	/**
	* 返回右侧高版本产品
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightProduct($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$high_product = $this->db->getOne("SELECT high_product 
									FROM won_product 
									WHERE id = {$id} AND won_product_delete = 0 ");
		
		$sql = "SELECT tab.url,p.product_name,p.product_box_middle,p.product_intro 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				LEFT JOIN Table_26 tab ON tab.Field_20044 = won_p.id 
				WHERE  FIND_IN_SET(won_p.id, '{$high_product}' ) AND won_p.won_product_delete = 0  LIMIT 1"; 
		$row = $this->db->getOneRs($sql);
		
		if (empty($row['url'])) {
			$sql = "SELECT tab.url,p.product_name,p.product_box_middle,p.product_intro 
					FROM won_product won_p 
					LEFT JOIN product p ON p.product_id = won_p.won_product_id 
					LEFT JOIN Table_45 tab ON tab.Field_20350 = won_p.id 
					WHERE FIND_IN_SET(won_p.id, '{$high_product}') AND tab.Field_20361 = 1 AND won_p.won_product_delete = 0 LIMIT 1";
			$row = $this->db->getAll($sql);
		
		}
		
		if (!empty($row)) {
			
			$row['url'] = url_replace($get['url'], $row['url'] ,'product_url');
			$row['product_name'] = str_replace('(português)' ,'' ,$row['product_name']) ;
			$str = '<div class="side_box210"><h4>Recomendação</h4><p class="pic"><a href="'.
					$row['url'].'"><img src="'.$row['product_box_middle'].'" alt="'.
					$row['product_name'].'" width="100" height="100" /></a></p><p class="tit"><a href="'.
					$row['url'].'">'.$row['product_name'].'</a></p><p class="dd">'.
					$row['product_intro'].'</p><p class="ar"><a href="'.
					$row['url'].'">Saiba mais&gt;&gt;</a></p></div>';
		}
		unset($row);
		return $str;
		
	}
	
	/**
	* 返回右侧留言
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightWord($get) {
		
		$str = '';
		$more_str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT review AS content, username AS user, date 
				FROM product_reviews_detail 
				WHERE pid = {$id} AND is_rec = 1";
		$row = $this->db->getOneRs( $sql );
		
		if ( empty( $row['content'] ) ) {
			$sql = "SELECT c.content,c.country,c.user 
					FROM won_product won_p 
					LEFT JOIN comment c ON c.product_id = won_p.won_product_id 
					WHERE won_p.id = {$id} AND c.delete = 0 AND  c.is_show=1 AND  won_p.won_product_delete = 0
					ORDER BY c.sort ASC LIMIT 1";
			$row = $this->db->getOneRs($sql);
		}
		
		$sql = "SELECT url FROM Table_44 WHERE Field_21624 = {$id} ";
		$url_reviews = $this->db->getOne($sql);
		
		if (!empty($url_reviews)) {
			$url_reviews = url_replace($get['url'] ,$url_reviews, 'product_url');
			$more_str = '<p class="moreReviews"><a href="'.$url_reviews.'">Mais avaliações >></a></p>';
		}
	
		if( !empty($row['content'])) {
			$str = '<div class="box1"><h4>Comentários dos usuários</h4><span class="fh1"></span><p>'.
					$row['content'].'</p><span class="fh2 fr"></span><div class="clear"></div><p class="dd2">-'.
					$row['user'].'</p>'.$more_str.'</div>';
		
		}
		unset($row);
		return  $str;
		
	}
	
	/**
	* 返回右侧tips
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightTips($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT tips FROM won_product   WHERE id = {$id} AND won_product_delete = 0 ";
		$tips = $this->db->getOne($sql);

		if($tips){
			$str = '<div class="side_box210"><h4>Tips</h4><ul>'.$tips.'</ul></div>';
		}
		
		return $str;
		
	}
	
	/**
	 * 返回右侧的superdownloads相关内容
	 * @return string
	 */
	function rightSuperDownload($get)
	{
// 		echo '<pre>'.print_r($get , true).'</pre>' ; exit ;
	    $url = 'http://www.superdownloads.com.br/download/175/wondershare-dvd-slideshow-builder-deluxe/' ;
		$content = '<div class="side_box210">
        <h4>Parceiros</h4>
        <p class="pic"><a background-color="#F2F2F2" href="'.$url.'"><img title="Parceria Superdownloads e Wondershare" alt="Parceria Superdownloads e Wondershare" width="142" height="80" src="http://images.wondershare.com.br/imagens/sd-logo.png" /></a></p>
    </div>' ;
		return $content ;
	}
	
	/**
	* 返回一级分类名称
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getSortName($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$cat_name  = '';
		$category_id = 0;
		
		$sql = "SELECT cat.parent_path 
				FROM won_product won_p 
				LEFT JOIN category cat ON won_p.cat_id = cat.cat_id 
				WHERE won_p.id = {$id} AND won_p.won_product_delete = 0 ";
		$parent_path = $this->db->getOne($sql);
		
		$row = explode(',', $parent_path);
		$category_id = $row[0];
		
		if (!empty($category_id)) {
			$sql_one = 'SELECT cat_title FROM category WHERE cat_id = '.$category_id.' ';
			$cat_name = $this->db->getOne($sql_one);
		}
		
		return $cat_name == "PC Utilities" ? 'PCUtilities' : $cat_name;
		
		
	}
	
	/**
	* 返回产品切换列表
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function switchPage($get) {
		
		//Overview
		$str = '';
		$tab_name = '' ;//切换页名称
		$id = (int) $get['产品ID'];
	
		$overview_class = '';
		$guide_class = '';
		$techspec_class = '';
		$reviews_class = '';
		
		if ($get['TID'] == '23') {//为wondershare切换表
			$tab_name = trim($get['产品切换名称']); 
			$overview_class = '';
		} else if($get['TID'] == '26') {//为wondershare产品默认页
			$overview_class = 'curr';
		} else if($get['TID'] == '34') {//为产品Guide页
			$guide_class = 'curr';
		} else if($get['TID'] == '33') {//为产品techspec页
			$techspec_class = 'curr';
		} else if($get['TID'] == '44') {//为产品评论页
			$reviews_class = 'curr';
		}
		
		$sql = "SELECT url FROM Table_26 WHERE Field_20044 = {$id} ";
		$p_url = $this->db->getOne($sql);
		
		if (empty($p_url)) {
			$sql = "SELECT url FROM Table_45 WHERE  Field_20350 = {$id} AND Field_20361 = 1";
			$p_url = $this->db->getOne($sql);
		}
	
		if (!empty($p_url)) {
			$p_url = url_replace($get['url'], $p_url, 'product_url');
			$str .= '<li><a href="'.$p_url.'" class="two '.$overview_class.'">Visão Geral</a></li>';
		}
		
		//Guide
		$sql = "SELECT url FROM Table_34 WHERE Field_20208 = {$id} ";
		$url_guide = $this->db->getOne($sql);
		
		if (!empty($url_guide)) {
			$url_guide = url_replace($get['url'], $url_guide, 'product_url');
			$str .= '<li><a href="'.$url_guide.'" class="one '.$guide_class.'">Guia</a></li>';
		}
		
		//切换页
		$sql = "SELECT won_attributes_id 
					FROM won_product 
					WHERE id = {$id} AND won_product_delete = 0 ";
		$att_str = $this->db->getOne($sql);
		
		$att_str = empty($att_str) ? 0: $att_str;
		
		$sql = "SELECT att.name,att.id,tab.url 
					FROM Table_23 tab 
					LEFT JOIN product_attributes att ON tab.Field_20073 = att.name 
					WHERE tab.Field_20071 = {$id} AND FIND_IN_SET(att.id,'".$att_str."') 
					ORDER BY tab.Field_20074 DESC ";
		$result = $this->db->query($sql);
		
		while ($row = $this->db->fetch_array($result)) {
			
			if (!empty($row['url'])) {
				$style = 'one';
				if (in_array(trim($row['name']), array("What's New", "Screenshot", "Templates", "DVD Menu"))) {
					$style = 'two';
				} 
				
				if ($tab_name == trim($row['name'])) {
					$style  .=' curr';
				}
				$row['url'] = url_replace($get['url'], $row['url'] ,'product_url');    
				$str.='<li><a href="'.$row['url'].'" class="'.$style.'">'.trim($row['name']).'</a></li>';
			}
		}
		
		//Tech Spec
		$sql = "SELECT url 
				FROM Table_33 
				WHERE Field_20182 = {$id} ";
		$url_tech = $this->db->getOne($sql);
		if (!empty($url_tech)) {
			$url_tech = url_replace($get['url'], $url_tech, 'product_url');
			$str .= '<li><a href="'.$url_tech.'" class="two '.$techspec_class.'">Especif. Téc.</a></li>';
		}
		
		//Reviews
		$sql = "SELECT url FROM Table_44 WHERE  Field_21624 = {$id} ";
		$url_reviews = $this->db->getOne($sql);
		
		if (!empty($url_reviews)) {
			$url_reviews = url_replace($get['url'], $url_reviews, 'product_url');
			$str .= '<li><a href="'.$url_reviews.'" class="one '.$reviews_class.'">Avaliações</a></li><li>&nbsp;</li>';
		}
		unset($row);
		return $str; 
		
		
	}
	
	/**
	* 返回下一页值  字符串
	* @param   array      		 $get       字段数组
	* @param   $value      		 下一页的值
	* @param   $next_url      		 下一页的url
	* @return  string
	*/ 
	
	function getNextStr($get, $value, $next_url)
	{
		
		$url = url_replace($get['url'], $next_url, 'product_url');
		
		$class = 'fl ';
		
		if ($get['sum'] == 0) {
			$img = 'http://images.wondershare.com.br/images/macintosh/mac-pdf-editor/coin_01.png';
		}else  {
			$class = 'fr noline';
			$img = 'http://images.wondershare.com.br/images/macintosh/mac-pdf-editor/coin_03.png';
		}
		
		$str = '<dl class="'.$class.'">
				<dd><img src="'.$img.'" width="32" height="32" /></dd>
				<dt><a href="'.$url.'">'.$value.'</a></dt>
				</dl>';
		
		return $str;
	}
	
	/**
	* 返回下一页Overview
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getNextOverview($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$p_name = trim( $get['产品名称']);
		$product_brand = $this->productBrand($get);
		
		$sql = "SELECT url FROM Table_26 WHERE  Field_20044 = {$id}";
		$url = $this->db->getOne($sql);
		
		if (empty($url)) {
			$sql = "SELECT url FROM Table_45 WHERE  Field_20350 = {$id} AND Field_20361 = 1";
			$url = $this->db->getOne($sql);
		}
		
		if (!empty($url)) {
			$str = $this->getNextStr($get, ' Visão geral do '.$product_brand.' '.$p_name, $url);
			$get['sum'] += 1;
		}
		return array('sum' =>$get['sum'], 'str' => $str );
		
	}
	/**
	* 返回下一页Guide
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getNextGuide($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$p_name = trim( $get['产品名称']);
		$product_brand = $this->productBrand($get);
		
		$sql = "SELECT url FROM Table_34 WHERE  Field_20208 = {$id}";
		$url = $this->db->getOne($sql);
		
		
		if (!empty($url)) {
			
			$str = $this->getNextStr($get, 'Ler a Guia de Usuário do '.$product_brand.' '.$p_name, $url);
			$get['sum'] += 1;
		}
		return array('sum' =>$get['sum'], 'str' => $str );
		
	}
	
	/**
	* 返回下一页切换页
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getNextTab($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$p_name = trim($get['产品名称']); 
		$product_brand = $this->productBrand($get);
		
		if (in_array($get['TID'], array('26', '33', '34'))) { 
			
			$limit = $get['TID'] == '26' ? 'LIMIT 1' : '';
			
			$sql = "SELECT att.name,att.id,tab.url 
						FROM Table_23 tab 
						LEFT JOIN product_attributes att ON tab.Field_20073 = att.name 
						WHERE tab.Field_20071 = {$id} AND att.id IN (
						    SELECT won_attributes_id 
						    FROM won_product 
						    WHERE id = {$id} AND won_product_delete = 0 ) 
						ORDER BY tab.Field_20074 DESC  {$limit} "; 
			
			if ($get['TID'] == '26') {
				
					$row = $this->db->getOneRs($sql);
					
					if (!empty($row['url'])) {
						
						$row['url'] = url_replace($get['url'], $row['url'], 'product_url');
						$value = get_next_name(stripslashes($row['name']), $product_brand.' '.$p_name);
						if( empty($value) ) return '';
						
						$str .= '<dl class="fl"><dd><img src="http://images.wondershare.com.br/images/macintosh/mac-pdf-editor/coin_01.png" width="32" height="32" /></dd>
								 <dt><a href="'.$row['url'].'">'.$value.'</a></dt></dl>';
						$get['sum'] = 1;
					}
					
			} else {
		
				$result = $this->db->query($sql);
				while ($row = $this->db->fetch_array($result)){
					
					if ($get['sum'] == 2) {
						break;
					}
					
					if (!empty($row['url'])) {
						
						$value = get_next_name(stripslashes($row['name']), $product_brand.' '.$p_name);
						if( empty($value) ) return '';
						$str .= $this->getNextStr($get, $value, $row['url']);
						
						$get['sum'] += 1;
					}
				
				}
			}
			
			unset($row);
			
		} else if ($get['TID'] == '23') {//切换页
		
			$tab_name = trim($get['产品切换名称']);
			
			$sql = "SELECT Field_20074  FROM Table_23 WHERE Field_20071 = {$id} AND Field_20073  = '{$tab_name}' ";
			
			$tab_sort = $this->db->getOne($sql);
			
			
			$sql =  "SELECT att.name,att.id,tab.url,tab.Field_20074 
						FROM Table_23 tab 
						LEFT JOIN product_attributes att ON tab.Field_20073 = att.name 
						WHERE tab.Field_20071 = {$id} AND tab.Field_20073 != '{$tab_name}' AND att.id IN (
						    SELECT won_attributes_id 
						    FROM won_product 
						    WHERE id = {$id} ) 
						ORDER BY tab.Field_20074 DESC ";
		
			$result = $this->db->query($sql);
			
			while ($row = $this->db->fetch_array($result)){
				
				if($get['sum'] == 2) {
					break;
				}
				
				
				if (($tab_name != addslashes($row['name'])) && ($row['Field_20074'] >= $tab_sort) && !empty($row['url'])) {
					
					$value = '';
					$value = get_next_name(stripslashes($row['name']), $product_brand.' '.$p_name);
					if( empty($value) ) return '';
					$str .= $this->getNextStr($get, $value, $row['url']);
					$get['sum'] += 1;
				}
			
			}
		}
		
		return array('sum' =>$get['sum'], 'str' => $str );
		
	}
	
	/**
	* 返回下一页Tech spec
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getNextTechspec($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$p_name = trim($get['产品名称']); 
		$product_brand = $this->productBrand($get);
		
		$sql = "SELECT url FROM Table_33 WHERE  Field_20182 = {$id} ";
	
		$url = $this->db->getOne($sql);
		
		if (!empty($url)) {
			
			$str .= $this->getNextStr($get, 'Ver as especificações do '.$product_brand.' '.$p_name, $url);
			$get['sum'] += 1 ; 
			
		}
		return array('sum' =>$get['sum'], 'str' => $str );
		
	}
	
	
	/**
	* 返回下一页Reviews
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getNextReviews($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$p_name = trim($get['产品名称']); 
		$product_brand = $this->productBrand($get);
		
		$sql = "SELECT url FROM  Table_44 WHERE  Field_21624 = {$id} ";
		$url = $this->db->getOne($sql);
		
		if (!empty($url)) {
			
			$str .= $this->getNextStr($get, 'Ler mais comentários sobre o '.$product_brand.' '.$p_name, $url);
			$get['sum'] += 1 ; 
			
		}
		return array('sum' =>$get['sum'], 'str' => $str );
		
	}
	
	/**
	* 下侧下一页和下下页
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function nextPage($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$p_name = trim($get['产品名称']);
		
			//产品默认页
		if ($get['TID'] == '26') { 
			
			$get['sum'] = 0;
			//guide页
			$arr = $this->getNextGuide($get);
			$str = $arr['str'];
			$get['sum'] = $arr['sum'];
			
			//切换页
			if ($get['sum'] < 2 ) {
				
				$arr = $this->getNextTab($get);
				if( !empty( $arr['str'] ) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}

			
			//Techspec
			if ($get['sum'] < 2 ) {
			
				$arr = $this->getNextTechspec($get);
				if( !empty( $arr['str'] ) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}
	
			
			//Reviews
			if ($get['sum'] < 2 ) {
			
				$arr = $this->getNextReviews($get);
				if( !empty( $arr['str'] ) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}
			
/* 			//Product Support
			if ($get['sum'] !=  0) {
			
				echo $sql = "SELECT url FROM Table_88 WHERE Field_20892 = {$id} " ;
				$url = $this->db->getOne($sql);
// 				echo $url ;exit ;//     /support.wondershare.com/httpdocs/dvd-creator-for-mac/index.html
				if (!empty($url)) {
					
					$url = str_replace(array('/support.wondershare.com.br/httpdocs', 'index.html'), 
										array('http://support.wondershare.com.br', ''), $url);
										
					$p_name = str_replace('Wondershare','', $p_name);
					$str .= '<dl class="fr noline">
							<dd><img src="http://images.wondershare.com.br/images/macintosh/mac-pdf-editor/coin_03.png" width="32" height="32" /></dd>
							<dt><a href="'.$url.'">Ver as Especif. Téc. do '.$p_name.' </a></dt>
							</dl>';
				}
			} */
		} else if(in_array($get['TID'], array('23','34')) ) ////产品切换页 和 guide页 模板
		{
			

			$get['sum'] = 0;
			
			//切换页
			$arr = $this->getNextTab($get);
			$str = $arr['str'];
			$get['sum'] = $arr['sum'];
			
			//tech spec
			if($get['sum'] < 2 ) {
				$arr = $this->getNextTechspec($get);
				if( !empty($arr['str']) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}
			//Reviews
			if ($get['sum'] < 2  ) {
			
				$arr = $this->getNextReviews($get);
				if( !empty($arr['str']) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}
			
			//Overview
			if ($get['sum'] < 2 ) {
			
				$arr = $this->getNextOverview($get);
				if( !empty($arr['str']) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
				
			}
			
			//guide页
			if($get['sum'] < 2 )
			{
				$arr = $this->getNextGuide($get);
				$str .= $arr['str'];
				
			}
		} else if(in_array($get['TID'], array('33','44'))  )//tech spec页 模板  和 产品评论
		{
			
			$get['sum'] = 0;
			if ($get['TID'] == '33') {
				
			    //Reviews
				$arr = $this->getNextReviews($get);
				if( !empty($arr['str']) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}
			
			//Overview
			$arr = $this->getNextOverview($get);
			if( !empty($arr['str']) ){
				$str .= $arr['str'];
				$get['sum'] += $arr['sum'];
			}

			//guide页
			if($get['sum'] < 2 )
			{
				$arr = $this->getNextGuide($get);
				if( !empty($arr['str']) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
				
			}
			
			//切换页
			if ($get['sum'] < 2 ) {
				
				$arr = $this->getNextTab($get);
				if( !empty($arr['str']) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}
			
			//tech spec
			if ($get['sum'] < 2 && $get['TID'] == '44') {
				
				$arr = $this->getNextTechspec($get);
				if( !empty($arr['str']) ){
					$str .= $arr['str'];
					$get['sum'] += $arr['sum'];
				}
			}
		}
		
		return $str;

	}
	
	/**
	* 返回是否是Win产品（显示Win图片）
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function isShowImage($get) {
		
		$id = (int) $get['产品ID'];
		$sql = "SELECT p.product_os,product_name 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0 ";
		
		$row = $this->db->getOneRs($sql);
		
		$icon_class = $get['TID'] == '26' ? ' class="icon" ' : '';
		
		if ($row['product_os'] == 'Win' && $row['product_name'] !='Wondershare DVD Slideshow Builder Standard') {
			return '<img src="http://images.wondershare.com.br/style/images0328/win_icon.png" alt="for Windows" '.$icon_class.' />';
		} else if ($row['product_os'] == 'Mac' ) {
			return '<img src="http://images.wondershare.com.br/style/images0328/mac_icon.png" '.$icon_class.' alt="for Mac" />';
		}
		unset($row);
		return '';
		
		
	}
	
	/**
	* 返回js跟踪代码
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function followingJsCode($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$tab_name = 'overview' ;
		
		//切换模板
		if($get['TID'] == '23') {
			$tab_name = trim($get['产品切换名称']); ;
		}
		
		$sql = "SELECT cat_title 
				FROM category 
				WHERE cat_id IN ( 
				    SELECT cat.parent_id 
				    FROM won_product won_p 
				    LEFT JOIN category cat ON won_p.cat_id = cat.cat_id 
				    WHERE won_p.id = {$id} AND won_p.won_product_delete = 0 ) ";
		$cat_title = $this->db->getOne($sql);
		
		$sql = "SELECT pro.product_name,pro.product_cbsid 
					FROM won_product won_p 
					LEFT JOIN product pro ON won_p.won_product_id = pro.product_id 
					WHERE won_p.id = {$id} AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);
		
		$str = 's.pageName="en:'.$cat_title.'::'.$row['product_name'].' overview";//pageName 
		s.channel="en";//site section    
		s.prop1="en:'.$cat_title.'"; //sub section 
		s.prop4="'.$tab_name.' pages";//page type
		s.products=";'.$row['product_cbsid'].'"; 
		s.prop5="'.$row['product_name'].'"; 
		s.events="prodView,event3";
		s.eVar3="browse";';
		
		return $str ;
		
		
	}
	
	/**
	* 返回对应的win或者mac产品
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function relWinMac($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];

		$sql = "SELECT p.product_os,p.product_rel,p.product_name 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);
		
		if (!empty($row['product_rel'])) {

			$sql = "SELECT tab.url,tab.Field_20045 as p_name 
						FROM won_product won_p 
						LEFT JOIN Table_26 tab ON won_p.id = tab.Field_20044 
						WHERE won_p.won_product_id = '{$row['product_rel']}' AND won_p.won_product_delete = 0 ";
			
			$row_p = $this->db->getOneRs($sql);
			$url  = $row_p['url'];
			
			if (empty($url)) {
				$sql = "SELECT tab.url,tab.Field_20351 as p_name 
							FROM won_product won_p 
							LEFT JOIN Table_45 tab ON won_p.id = tab.Field_20350 
							WHERE won_p.won_product_id = '{$row['product_rel']}' ";
				$row_p = $this->db->getOneRs($sql);
				
				$url  = $row_p['url']; 
			}
			
			$url = url_replace($get['url'], $url, 'product_url');
			$p_name = $row_p['p_name'];
			
			if ($row['product_os'] == 'Win') {
				if (substr_count($p_name, 'for Mac') == 0) { 
					$str_mac = 'for  Mac ';
				}
// 				$str = ' <a href="'.$url.'"  > Versão para Win>> </a>';
				$str = ' <a href="'.$url.'"  > Versão para Mac>> </a>';
			} else if ($row['product_os'] == 'Mac') {
				if (substr_count($p_name, 'for Mac') > 0 ) {
					$str = ' <a href="'.$url.'" > Versão para Mac>> </a>';
				} else {
					$str = ' <a href="'.$url.'"> Versão para Win>> </a>';
				}
			}
		}
		unset($row, $row_p);
		return $str;
		
	}
	
	/**
	* 返回右侧Awards
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightAwards($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$sql = "SELECT awards_image 
				FROM won_product 
				WHERE id = {$id} AND won_product_delete = 0 ";
		$awards_image = $this->db->getOne($sql);
		
		if ($awards_image) {
			return '<div class="side_box210"><h4>Prêmios</h4>
			<p class="pic"><img src="'.$awards_image.'" width="142" height="133" /></p>
			</div>';
		} else {
			return '';
		}
	}
	
	/**
	* 返回右侧Comparison
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightComparison($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT c.url ,c.Field_20363 
				FROM Table_26 p 
				LEFT JOIN Table_32 c ON p.Field_20252 = c.Field_20181 
				WHERE p.Field_20252 != '0' AND p.Field_20044 = {$id}";
		$row = $this->db->getOneRs($sql);
		
		if (!empty($row['url'])) {
			$row['url'] = url_replace($get['url'], $row['url'], 'product_url');
			$str = '<div class="side_box210">
					<h4>Comparison</h4>     
					<p class="pic"><a href="'.$row['url'].'
					"><img src="http://images.wondershare.com.br/images/macintosh/more-features/comparison.png"></a></p>
					<p class="dd">'.$row['Field_20363'].'
					</p>
					<p class="ar"><a href="'.$row['url'].'">Mais Detalhes&gt;&gt;</a></p>
					</div>';
		}
		unset($row);
		return $str;
	}
	
	/**
	* 返回跟踪url
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function followingUrl($get) {
		
		$url = str_replace(array('index.html', '/wondershare.com.br/httpdocs/'), 
							array('', 'http://www.wondershare.com.br/'), $get['url']);
		$url = 'addthis:url="'.$url.'"';
		
		return $url;
	}
	
	
	/**
	* 返回右侧视频弹出html
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function rightVideoPopup($get) {
		
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT p.product_video_promo,p.video_width,p.video_higth,p.product_id 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);
		
		if ($row['product_video_promo'] == '') {
			return '';
		}
		
		$is_youtube = 0;//用于判断是否有youtube视频 0为木有 ，1为有
		$video_arr = explode('.', $row['product_video_promo']);
		$video_type = $video_arr[count($video_arr) - 1];
		
		$version = get_sale_version($row['product_id']);
		$download_url = $version['download_url'];
		
		//用于初始化youtube弹出框 以及图片弹窗口加载的js以及css
		$str = '<link rel="stylesheet" type="text/css" href="http://images.wondershare.com.br/script/fancybox-2.0.1.css" media="screen" />
				<script type="text/javascript" src="http://images.wondershare.com.br/script/fancybox-2.0.1.js"></script> ';
		
		if ($video_type == 'swf') {
		
			$video = '<embed width="'.max($row['video_width'], 560).'" height="'.$row['video_higth'].'" flashvars="width='.
						max($row['video_width'],560).'&height='.$row['video_higth'].'&file='.
						$row['product_video_promo'].'&backcolor=0xff8c00&frontcolor=0xE2F0FE" allowfullscreen="true" quality="high" name="mediaplayer" id="mediaplayer" style="undefined" src="'.
						$row['product_video_promo'].'" type="application/x-shockwave-flash"></embed>';
		
		} else if($video_type == 'flv') {
		
			$video = '<embed width="'.max($row['video_width'],560).'" height="'.$row['video_higth'].'" flashvars="width='.
						max($row['video_width'],560).'&height='.$row['video_higth'].'&file='.
						$row['product_video_promo'].'&backcolor=0xff8c00&frontcolor=0xE2F0FE&wmode=Opaque" allowfullscreen="true" quality="high" name="mediaplayer" id="mediaplayer" style="undefined" src="http://www.wondershare.com/pro/demo/FlvPlayerV2009.swf" type="application/x-shockwave-flash"></embed>';
		
		} else if($video_type == 'mov' || $video_type == 'm4v') {
		
			$video = '<embed src="'.$row['product_video_promo'].'" width="'.max($row['video_width'],550).'" height="'.
					$row['video_higth'].'"></embed>';
		
		}else if (substr_count($row['product_video_promo'], 'http://www.youtube.com/') > 0 ) {
			$is_youtube = 1;
			$url = str_replace('/embed/','/v/', $row['product_video_promo']);
			$video = '<object width="560" height="315"><param name="movie" value="'.$url.'"></param>
						<param name="allowFullScreen" value="true"></param>
						<param name="allowscriptaccess" value="always"></param>
						<embed src="'.$url.'" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed>
						</object>';
		}else{
			return '';
		}
		
		//以下判断特点是否有大配图  如果有则加载弹出大图片的js
		$sql = 'SELECT COUNT(*) nums 
				FROM feature 
				WHERE product_id = '.$row['product_id'].' AND feature_pic_max!= "" AND is_delete = 0 ' ;
		$nums = $this->db->getOne($sql);
		
		if ($nums > 0) {
		
			if ( $is_youtube == 0 ) {
				$str .= $fancybox_str;	
			}
			$str .= '<script type="text/javascript"> 
					$(document).ready(function() {
					$("a.zoom").fancybox();
					$("a.zoom1").fancybox({
					\'overlayOpacity\'	:	0.7,
					\'overlayColor\'	:	\'#ccc\'
					});
					});
					</script> ';
		}
		
		$str .= '<script type="text/javascript"> 
				$(document).ready(function() {
				$(".videoDemo").fancybox({
				\'width\'				: 600,
				\'height\'				: 480,
				\'autoScale\'			: false,
				\'transitionIn\'		: \'none\',
				\'transitionOut\'		: \'none\'
				});});
				</script> ';
		
		$str .= '<div id="video-demo" style="display:none">';
		$str .= $video;		
		$str .= '<div class="clear"></div>
				<a class="btn_trial fl mt15" href="'.$download_url.'">Free Trial</a>
				<p class="videoshare">Share the video:</p>
				<div class="mt15 addthis_toolbox addthis_default_style " addthis:url="'.$row['product_video_promo'].'">
				<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
				<a class="addthis_button_tweet"></a>
				<a class="addthis_button_google_plusone" g:plusone:size="Medium"></a>
				</div>
				</div>';
		
		return $str;
	}
   
	/**
	* 返回lion图片地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function lionPicUrl($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];

		$sql = "SELECT lion_url 
				FROM won_product 
				WHERE id = {$id} AND won_product_delete = 0 ";
		$lion_url = $this->db->getOne($sql);
		
		if (!empty($lion_url)) {
			$str = '<div class="video"><img src="'.trim($lion_url).'" alt="Lion" /></div>';
		}
		return $str;
		
	}
	
	/**
	* 返回xmlns代码
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function xmlnsHtml($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		//产品单页管理
		if ($get['TID'] == '45') { 
			
			if ($id == 106) {
				return '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">';
			}else
			{
				 return '<html xmlns="http://www.w3.org/1999/xhtml">';
			}
			
		} else {
			
			if ($id == 19)
			{
				return '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#">';
			} elseif( in_array($id, array(2, 3, 4, 9, 11, 13, 20, 21, 39, 53, 54, 56, 57 )))
			{
				return '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">';
			} else {
				return '<html xmlns="http://www.w3.org/1999/xhtml">';
			}
		}
		
		
	}
	
	
	
	/**
	* 返回文字广告
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function textAd($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT ad.ad_url,ad.ad_content 
				FROM ad_delivery ad_d 
				LEFT JOIN ad ad ON ad.ad_id = ad_d.ad_id 
				WHERE ad_d.ws_id = {$id} AND ad_d.is_text_ad = 1 AND ad.is_delete = 0 LIMIT 1 ";
		$rows = $this->db->getOneRs($sql);
		
		if (!empty($rows)) {
			
		  $str = '<p class="promotext"><a href="'.$rows['ad_url'].'">'.$rows['ad_content'].' >></a></p>';
		}
		return $str;
	}
	
	/**
	* 返回产品视频绝对地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function videoAbsoluteUrl($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$product_id = $this->db->getOne("SELECT won_product_id FROM  won_product WHERE id = {$id} AND won_product_delete = 0 ");
		
		if (!$product_id) {
			return '';
		}
		
		$product_video_promo = $this->db->getOne("SELECT product_video_promo FROM  product WHERE  product_id = '{$product_id}' ");
		return $product_video_promo;
	}
	
	/**
	* 返回面包屑
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function bread($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$cat_id = $this->db->getOne("SELECT  cat_id FROM won_product  WHERE id = {$id} AND won_product_delete = 0 ");
		$cat_top_id2 = $this->db->getOne("SELECT parent_id FROM category  WHERE cat_id = '{$cat_id}' ");
		
		if (!$cat_id || !$cat_top_id2) {
			return '';
		}
		$rs = $this->db->getOneRs("SELECT cat.cat_title,t.url,t.Field_20243 FROM category as cat 
							LEFT JOIN  Table_42 AS t on cat.cat_title = t.Field_20243 
							WHERE  cat.is_delete=0 AND cat.cat_type=2 AND cat.cat_web=1 AND cat.cat_id= '{$cat_top_id2}' LIMIT 1");
		
		if ($rs) {
			$cat_title = $rs['Field_20243'];
			$url = str_replace('/wondershare.com.br/httpdocs/', 'http://www.wondershare.com.br/', $rs['url']);
			$str = "<a href='".$url."'>".$cat_title."</a>"; 
		}
		
		$cat_top_id1 = $this->db->getOne("SELECT parent_id FROM category  WHERE cat_id= '$cat_top_id2' ");
		if (!$cat_top_id1) {
			return '';
		}
		$top_rs = $this->db->getOneRs("SELECT t.url,t.Field_20235 
								FROM category AS cat 
								LEFT JOIN  Table_41 AS t on cat.cat_title = t.Field_20235 
								WHERE  cat.is_delete=0 AND cat.cat_type=2 AND cat.cat_web=1 AND cat.cat_id= '{$cat_top_id1}'");
		if ($top_rs) {
			$cat_title = $top_rs['Field_20235'];
			$url = str_replace('/wondershare.com.br/httpdocs/', 'http://www.wondershare.com.br/', $top_rs['url']);
			$parent_str = "<a href='".$url."'>".$cat_title."</a> <span></span>"; 
		}
		return $parent_str.$str;
	}
	
	/**
	* 返回对应下载与免费中
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function toDownloadAndPriceMid($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT p.product_rel 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE id = {$id} AND won_p.won_product_delete = 0  ";
		$rel_id = $this->db->getOne($sql);
		
		if( $rel_id == 0 ) {
			return '';
		}
		
		$old = $year_str = $new = '';
		
		$sql = "SELECT p.product_isfree ,p.product_id, p.product_type,p.product_brand,p.product_name,p.product_version ,p.product_is_year_charge,won_p.giveaway,won_p.getcodeurl 
				FROM won_product won_p 
				LEFT JOIN product p ON p.product_id = won_p.won_product_id 
				WHERE won_p.id = '{$rel_id}' AND won_p.won_product_delete = 0 ";
		$row = $this->db->getOneRs($sql);
		
		if ($row['product_brand'] == 'Wondershare') {
			$brand_type = "WS/";
		} elseif ($row['product_brand'] == 'iSkysoft') {
			$brand_type = "IS/";
		}
		$product_name = trim(str_replace($row['product_brand'], '', $row['product_name']));
		$price_arr = get_price($row['product_id']);
		$new = $price_arr['curr'];
		
		$version = get_sale_version($row['product_id']);
		$row['product_version'] = $version['version_name'];

		
		$download_jump_url = $version['download_url'];
		
		
		$sql = "SELECT url FROM Table_39 WHERE Field_20326 = '{$row['product_id']}'";
		$buy_url = $this->db->getOne($sql);
		if (empty($buy_url)) {
			$sql = 'SELECT url FROM Table_74 WHERE Field_20734 = '.$row['product_id'];
			$buy_url = $this->db->getOne($sql);
		}
		$buy_url = url_replace($get['url'], $buy_url, 'buy_url');
		
		if ($id == 39) {
			$buy_url = 'http://store.wondershare.com.br/shop/buy/buy-mac-pdf-editor-pro.html';
		}
		
		if ($price_arr['unique']) {
			$old = 'R$'.$price_arr['old'];
		}
		
		if($row['product_is_year_charge']) {
			$year_str = '/year';
		}
		
		$ver_count = count(explode('.', $row['product_version'])); 
		
		if ($ver_count > 3) {
			$product_version = substr($row['product_version'],0, strrpos($row['product_version'], '.'));
		} else {
			$product_version  = $row['product_version'];
		}
		$click_url = "var that=this;_gaq.push(['_trackEvent', this.href, 'Download', document.location.pathname]); _gaq.push(['_trackPageview', this.href]); setTimeout(function(){location.href=that.href;},100);return false;";
		
		if ($row['product_isfree'] == 1) {
			$str = '<a  href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url.'"  class="download fl" >
					<span class="dd">Versão: '.$product_version.'</span><span class="security"><img height="18" width="25" src="http://images.wondershare.com.br/style/images0328/pro_06.png">Secure Download</span></a>';
		} else {
		
			if ($row['product_type'] == 1) {
				$str = '<a href="'.$download_jump_url.'" rel="nofollow" onClick="'.$click_url.'"  class="free fl">
						<span class="dd">Versão: '.$product_version.'</span><span class="security"><img height="18" width="25" src="http://images.wondershare.com.br/style/images0328/pro_06.png">Secure Download</span></a>';
			}
			if ($row['giveaway'] == 1) {
				$new = str_replace('.', ',', $new) ;
				$str .= '<a href="'.$row['getcodeurl'].'" class="getfree fr" onclick="'.$click_url.'"><span class="dd"><span style="text-decoration:line-through" >R$'.$new.$year_str.'</span> Free</span></a>';
			} else {
				$old = str_replace('.', ',', $old) ;
				
				$new = $new / 6.00 ;
				$new = substr($new, 0 , strpos($new, '.') + 3 );
				$new = str_replace('.', ',', $new) ;
				$str .= '<a href="'.$buy_url.'" class="buy2 fl"><span class="dd"><span style="text-decoration:line-through" >'.$old.'</span> Apenas 6x R$ '.$new.$year_str.'</span><span class="security"><img height="18" width="25" src="http://images.wondershare.com.br/style/images0328/pro_08.png">90 dias de garantia de devolução</span></a>';
			}
		}
		return  $str;
	}
	
	/**
	* 返回googleCode
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function googleCode($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		$googCode = getGoodCode($id, 'google_code_oview');
		return $googCode ? $googCode : '';
	}
	
	/**
	* 返回购买显示
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function buyShow($get) {
		
		$str = '';
		$id = $get['产品ID'];
		$row = parent::productInfo( $id );
		$rel = $row['product_rel'];
	
		if ( empty( $rel ) ){
			$str = "<dl>".$this->productBuySome($get)."
					<dt>Requirements: <strong>".$this->sysSupportShot($get)."</strong></dt>
					</dl>
					<div class=\"btn\">".$this->downloadAndPriceMid($get)."</div>";
			return $str;
		} else {
		
			$sql = "SELECT p.product_rel 
					FROM won_product won_p 
					LEFT JOIN product p ON p.product_id = won_p.won_product_id 
					WHERE id = '{$id}' AND won_p.won_product_delete = 0 ";
		
			$rel_id = $this->db->getOne($sql);
			
			$sql = "SELECT p.product_support_intro 
					FROM won_product won_p 
					LEFT JOIN product p ON p.product_id = won_p.won_product_id 
					WHERE won_p.id = '{$rel_id}' AND won_p.won_product_delete = 0";
			
			$support_intro = $this->db->getOne($sql);
			
			$sql = "SELECT p.product_isfree, p.product_id, p.product_type, p.product_version, p.product_os, p.product_is_year_charge, won_p.giveaway 
					FROM won_product won_p 
					LEFT JOIN product p ON p.product_id = won_p.won_product_id 
					WHERE won_p.id = '{$id}' AND won_p.won_product_delete = 0 "; 
			
			$row = $this->db->getOneRs($sql);
			
			$sql = "SELECT p.product_isfree,p.product_type
			FROM won_product won_p LEFT JOIN product p ON p.product_id = won_p.won_product_id 
			WHERE won_p.id = '{$rel_id}' AND won_p.won_product_delete = 0 ";  
	
			$row_rel = $this->db->getOneRs($sql);
			
			$str = "<dl>".$this->productBuySome($get)."</dl>
					<hr /><strong>Supported OS:</strong>
					<label><input name=\"supported\" checked=\"checked\" type=\"radio\" onclick=\"$('.pro_bg .text .btn-".
					($row['product_os']=='Win'?'win':'mac')."').show();$('.pro_bg .text .btn-".
					($row['product_os']=='Win'?'mac':'win')."').hide();\" /> 
					".$this->sysSupportShot($get)."</label>
					<label class=\"mb5\"><input name=\"supported\" type=\"radio\" onclick=\"$('.pro_bg .text .btn-".
					($row['product_os']=='Win'?'mac':'win')."').show();$('.pro_bg .text .btn-".
					($row['product_os']=='Win'?'win':'mac')."').hide();\" /> $support_intro ".
					$this->relWinMac($get)."</label>";
			
			$str .= "<div class=\"btn btn-".($row['product_os']=='Win'?'win':'mac')."\">".
					$this->downloadAndPriceMid($get)."</div>";
			
			$str .= "<div class=\"btn btn-".($row['product_os']=='Win'?'mac':'win')."\" style=\"display:none;\">".
					$this->toDownloadAndPriceMid($get)."</div>";
			
/*			if ( $row['product_type'] == 1 ) {
				$str .= '<span class="security btn-'.($row['product_os']=='Win'?'win':'mac').'">
						<img src="http://images.wondershare.fr/style/images0328/pro_06.png" width="25" height="18" />Secure Download</span>';
			}
			
			if ( $row['product_isfree'] == 0 ) {
				$str .= '<span class="btn-'.($row['product_os']=='Win'?'win':'mac').'">
						<img src="http://images.wondershare.fr/style/images0328/pro_08.png" width="25" height="18" />90 Days Money Back Guarantee</span>';
			}
			
			if ( $row_rel['product_type'] == 1 ) {
				$str .= '<span class="security btn-'.($row['product_os']=='Win'?'mac':'win').'" style="display:none;">
						<img src="http://images.wondershare.fr/style/images0328/pro_06.png" width="25" height="18" />Secure Download</span>';
			}
			
			if ( $row_rel['product_isfree'] == 0  ) {
				$str .= '<span class="btn-'.($row['product_os']=='Win'?'mac':'win').'" style="display:none;">
						<img src="http://images.wondershare.fr/style/images0328/pro_08.png" width="25" height="18" />90 Days Money Back Guarantee</span>';
			}*/
			
			return $str;
		}
		
	}
	
	/**
	* 返回(切换页)视频js
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function videoJs($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql  = "SELECT url FROM Table_43  WHERE Field_20309 = {$id}";
		$video_promo_url = $this->db->getOne($sql);
		if ($video_promo_url) {
			$str = "$('a.iframe').fancybox({
					'width'				: 650,
					'height'			: 480,
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
					});";
		
		}
		
		return  $str;
		
	}
	
	/**
	* 返回(ws产品二级分类页模板)处理后一级分类名称
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function oneCategoryName($get) {


		return trim($get['产品一级分类名称']) == "PC Utilities" ? 'PCUtilities' : trim($get['产品一级分类名称']);
		
		
	}
	
	/**
	* 返回(切换页)切换内容
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function switchContent($get) {
		
		$page_content = '' ;
		$id = (int) $get['产品ID'];
		$tab_name = trim($get['产品切换名称']);
		
		$sql = "SELECT id FROM  product_attributes  WHERE name = '{$tab_name}' ";
		$tab_id = $this->db->getOne($sql);
		
		if (!empty($tab_id)) {
			$sql = "SELECT page_content  FROM product_page WHERE product_id = {$id} AND article_id = '{$tab_id}' ";
			$page_content = $this->db->getOne($sql);
		}
		return $page_content;
		
		
	}
	
	/**
	* 返回(Tech-Spec)版本控制
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function license($get) {
		
		$str = '';
		$id = (int) $get['产品ID'];
		
		$sql = "SELECT ver.version_name,ver.whatisnew_content 
				FROM version  ver
				LEFT JOIN product p ON p.product_id = ver.product_id 
				LEFT JOIN won_product  won_p  ON p.product_id = won_p.won_product_id 
				WHERE won_p.id = {$id} AND ver.is_sale =1 AND won_p.won_product_delete = 0";
		$row = $this->db->getAll($sql);
		
		if (!empty($row)) {
			for ($i = 0; $i < count($row); $i++) {
				
				$ver_count = count(explode('.',$row[$i]['version_name'])); 
				
				if ($ver_count > 3) {
					$product_version = substr($row[$i]['version_name'], 0, strrpos($row[$i]['version_name'], '.'));
				} else {
					$product_version  = $row[$i]['version_name'];
				}
				
				$whatisnew_content = str_replace(array("\n", "What's New:", "what's new:") ,array('<br>', '', ''), $row[$i]['whatisnew_content']);
				
				$str .= "<h2 class='noline'>What's New in Version ".htmlspecialchars($product_version)."</h2>
						<ul>".$whatisnew_content."</ul>";
			}
			 $str;
		} 
		
		return $str;
	}
	
	
	/**
	* 评论信息
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function reviews($get) {
		$id = $get['产品ID'];
		
		$sql = "SELECT url FROM Table_44 WHERE Field_21624 = '{$id}'";
		$url_reviews = $this->db->getOne($sql);
		
		if( empty($url_reviews) ) {
			return '';
		}

		$url_reviews = url_replace($get['url'],$url_reviews ,'product_url');
		
		$str = parent::reviews( $id, $url_reviews );
		return $str;
	}
	

	
	//note 写评论地址
	function reviewsWriteUrl($get) {
		$id = $get['产品ID'];
		$product_brand = $this->productBrand($get);
		
		$str = 'http://www.wondershare.com.br/reviews/reviews-write.html';
		$str .= '?pid='.$id;
		$str .= '&p='.$product_brand;
		
		$row = parent::productInfo( $id );
		
		$str .= '&n='.urlencode($row['product_name']);
		
		if ( $row['product_os'] == 'Win' && $row['product_name'] !='Wondershare DVD Slideshow Builder Standard') {
			$str .= '&os=Windows';
		} else if($row['product_os'] == 'Mac' ) {
			$str .= '&os=Mac';
		}
		
		return $str;	
	}
	
	/**
	* 产品价格前台显示
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productPriceShow($get) {

		$str = '';
		$arr = parent::productPriceOldAndCurr($get);//得到价格信息
		
		$str = '<strong class="price">'.$arr['curr'].'</strong> <del>'.$arr['old'].' </del>' ;
		return $str;	
	}
	
	/**
	* 产品下载跳转地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productDownloadJumpUrl($get) {

		$id = (int) $get['产品ID'];
		$sql = "SELECT url FROM Table_194 WHERE Field_22053 = {$id} LIMIT 1 ";
		$url = $this->db->getOne($sql);
		
		if (!empty($url)) {
			return str_replace(array('/wondershare.com.br/httpdocs', 'index.html'), array('http://www.wondershare.com.br', ''), $url);
		 	
		} else {
			return '';
		}
		
		
	}
	
	
	/**
	* 产品购买地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productBuyUrl($get) {

		
		$id = (int) $get['产品ID'];
		$url = '';
		
		$sql = "SELECT url FROM Table_39 WHERE Field_20326 = {$id} LIMIT 1 ";
		$url = $this->db->getOne($sql);
		
		if (empty($url)) {
			$sql = "SELECT url FROM Table_74 WHERE Field_20734 = {$id} LIMIT 1 ";
			$url = $this->db->getOne($sql);
		}
		$url = url_replace('', $url, 'buy_url');
		
		return $url;
	}
	
	/**
	* 绑定相关产品
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function bindingRelatedProduct($get) {

		$str = '';
		$result = parent::bindingRelatedProductInfo($get);
		if (empty($result)) {
			return '';
		}
		
		$i = 0;
		while ($row = $this->db->fetch_array($result)) {
			
			if ($row['product_type'] == 1) { //是否试用
				
				$get['产品ID'] = $row['id'];
				$product_url = $this->productUrl($get);//得到产品url
				$downLoad_url = parent::productDownLoadUrl($get);//得到产品下载链接
				
				if ($i != 0 ){
					$str .= '<div class="item">';
				}
				$str .=  
				'<div class="img"><a href="'.$product_url.'"><img src="'.$row['product_box_middle'].'" /></a></div>
                <h3><a href="'.$product_url.'">'.$row['product_name'].'</a></h3>
                <p>'.$row['product_intro'].'</p>
                <a href="'.$downLoad_url.'" 
                onclick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]); _gaq.push([\'_trackPageview\', this.href]); 
                setTimeout(function(){location.href=that.href;},100);return false;" class="trialBtn" target="_blank" ></a>
            	</div>';
				$i = $i + 1;
			}
		}
		
		$get['产品ID'] = $id;
		
		$str_before = ' <h2>Customers who liked '.$get['产品名称'].', also bought:</h2> <div class="box3">';
		
		if( $i > 1) {
			$str = $str_before.'<div class="item borR">'.$str.'</div>';
		} else if($i == 1) {
			$str = $str_before.'<div class="item">'.$str.'</div>';
		}else {
			return '';
		}
		
		unset($row);
		return $str;
	}
	
	/**
	* 产品地址
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productUrl($get) {
		
		$url = '';
		$id = (int) $get['产品ID'];

		$sql = "SELECT tab.url 
				FROM won_product won_p 
				LEFT JOIN Table_26 tab ON tab.Field_20044 = won_p.id 
				WHERE won_p.id = {$id} ";
		$url = $this->db->getOne($sql);
		
		if (empty($url)) {
			
			$sql = "SELECT tab.url 
					FROM won_product won_p 
					LEFT JOIN Table_45 tab ON tab.Field_20350 = won_p.id 
					WHERE won_p.id = {$id} ";
			$url = $this->db->getOne($sql);
		}
		
		$url = str_replace('index.html','',str_replace('/wondershare.com.br/httpdocs/','http://www.wondershare.com.br/',  $url)); 
			
		return $url;
	}
	
	/**
	* 最后一条产品评论以及作者
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function productLastReviews($get) {

		$str = '';
		$rows = parent::productLastReviewsInfo($get);
		
		if (!empty($rows)) {
			
			$str = 
			'<div class="info">
            <strong>'.$get['产品名称'].' users review </strong>
            <div class="img"><img src="http://images.wondershare.com.br/style/images/good_03.png" /></div>
            ';
			
			$str .= '<p>'.$rows['review'].'</p><span class="fr">————'.$rows['username'].'</span></div>';
		}
		
		return $str;
		
	}
	
	/**
	* 下载跳转步骤
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function downloadJumpSteps($get) {

		$str = '';
		if ($get['选择类型'] == 1 ) { //代表为Win类型
			
			$str = '<div class="box1">
					<div class="item">
					<span class="num">1.</span>
					<p>Depending on your connection speed, the download may take up to a few minutes.</p>
					<img src="http://images.wondershare.com.br/images/thankyou/win1.jpg">
					</div>
					<div class="item">
					<span class="num">2.</span>
					<p>The Product setup wizard will be launched.</p>
					<img src="http://images.wondershare.com.br/images/thankyou/win2.jpg">
					</div>
					<div class="item">
					<span class="num">3.</span>
					<p>Double-click the software icon to open the application.</p>
					<img src="http://images.wondershare.com.br/images/thankyou/win3.jpg">
					</div>
					</div>';
			
		} else if($get['选择类型'] == 2) {//代表为Mac类型
			
			$str = '<div class="box1">
					<div class="item">
					<span class="num">1.</span>
					<p>Double-click the .DMG file to open it up and a Finder window will appear.</p>
					<img src="http://images.wondershare.com.br/images/thankyou/mac1.jpg">
					</div>
					<div class="item">
					<span class="num">2.</span>
					<p>Drag and drop the Application icon into your "Applications" directory.</p>
					<img src="http://images.wondershare.com.br/images/thankyou/mac2.jpg">
					</div>
					<div class="item">
					<span class="num">3.</span>
					<p>Double-click the software icon to open the application.</p>
					<img src="http://images.wondershare.com.br/images/thankyou/mac3.jpg">
					</div>
					</div>';
		}

		return $str;
		
	}
	
	/**
	* 得到评论列表和分页信息 
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function reviewsCreatePage($get = array() ) {
		
		$id = (int) $get['产品ID'];
		
	
		$DirName = dirname($get['url']);
		$dirurl = str_replace('/wondershare.com.br/httpdocs/','',$DirName);
		//不预览
		$template_str = $this->replaceTemplateAndGet($get['tem_style']);
		$get['do'] = isset($get['do']) ? $get['do'] : '';
		if ( $get['do'] != 'view') {
			
			$dir = DOC_ROOT.'/'.$DirName;
			MakeDir1($dir);
			
			if (!is_dir($dir)) {
				$DirName = DOC_ROOT.'/wondershare.com.br/httpdocs';
			}
		}
		
		$sql = "SELECT * FROM product_reviews_detail WHERE pid = {$id} AND check_state = 1 ORDER BY `date` DESC";
		$all = $this->db->getAll($sql);
		
		/************************* 全部 ********************************************/
		$total = count($all);
		$max_page = ceil($total / 10);
		for ($i = 1; $i <= $max_page; $i++) {
		
			$temp = $template_str;
			$page_start = ($i - 1) * 10 + 1;
			$page_end = ($i - 1) * 10 + 10;
			
			if( $page_end >= $total) {
				$page_end = $total;
			}
			
			$list = '';
			$chang_sum = 0;
			for ($j = ($i - 1)* 10; $j <= $i * 10 - 1; $j++) {
				
				if ($j >= $total) {
					break; 	
				}  
			
				$list .= '<div class="reviewsItem">
				<div  class="rating">
				<ul>
				<li '.($all[$j]['star'] >= 1 ? 'class="on"' : '').'><a href="javascript:;">1</a></li>
				<li '.($all[$j]['star'] >= 2 ? 'class="on"' : '').'><a href="javascript:;">2</a></li>
				<li '.($all[$j]['star'] >= 3 ? 'class="on"' : '').'><a href="javascript:;">3</a></li>
				<li '.($all[$j]['star'] >= 4 ? 'class="on"' : '').'><a href="javascript:;">4</a></li>
				<li '.($all[$j]['star'] >= 5 ? 'class="on"' : '').'><a href="javascript:;">5</a></li>
				</ul>
				</div>
				<strong class="title">'.str_replace('\\','',$all[$j]['title']).'</strong><br/>
				<span class="info">'.$all[$j]['username'].' | '.$all[$j]['date'].'</span>
				<div class="clear"></div>		
				<p class="con">'.str_replace(array("\\","\r\n"),array('','<br/>'),$all[$j]['review']).'</p>
				
				<div class="ud"><a href="javascript:s_o('.$all[$j]['did'].',1);" class="up"></a>
				<span class="fl" id="support_'.$all[$j]['did'].'">'.$all[$j]['support'].'</span><a href="javascript:s_o('.$all[$j]['did'].',2);" class="down"></a>
				<span class="fl" id="oppose_'.$all[$j]['did'].'">'.$all[$j]['oppose'].'</span></div>
				<div class="addthis_toolbox addthis_default_style share fr"> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a></div>';
				
				if( !empty($all[$j]['reply']) ) {
					$list .= '<div class="clear"></div><p class="reply"><strong>Wondershare:</strong><br />'.$all[$j]['reply'].'</p>';
				}
				
				$list .= '<div class="btm"></div></div>';
			}
		
			//分页
			$page = '<div class="paging">';
			if ( $i  > 1 ) {
				if($i -1 == 1){
				$page .= '<a href="'.'../../'.$dirurl.'/" class="prev">Prev</a>';
				}else{
					$page .= '<a href="'.'../../'.$dirurl.'/'.($i-1).'.html" class="prev">Prev</a>';
				}
			} else {
				$page .= '<a class="prev">Prev</a>';
			}
		
		
			$start = $i - 4;
			$end = $i + 4;
			if ($start < 1) {
				$start = 1; $end = 6;
			}
			
			if ($end > $max_page) {
				$end = $max_page; $start = $max_page - 5;
			}
			
			if ($start < 1) {
				$start = 1;
			}
			
			if ($start != 1) {
				$output .= '';	
			}
			
			for ($start; $start <= $end; $start++) {
				
				if ($i == $start) 
				{
					$page .= '<strong>'.$start.'</strong>';
				} else {
					if ($start == 1) {
						$page .= '<a href="'.'../../'.$dirurl.'/">'.$start.'</a>';
					} else {
						$page .= '<a href="'.'../../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
					}
				}
			}
			
			if ($end != $max_page) {
				$output .= '';
			}
			if ($i < $max_page) {
				$page .= '<a href="'.'../../'.$dirurl.'/'.($i+1).'.html" class="next">Next</a>';
			} else  {
				$page .= '<a class="next">Next</a>';
			}
		
			if ( $total == 0 ) {
				$page = '<div class="paging">';	
			} 
		
			$page = $list.$page.'</div>';

			if (isset($get['do']) && $get['do'] == 'view') {
				return $page;
			}
			
			$temp = str_replace("<!--page_module-->", $page, $temp);
			$temp = str_replace('$'.'{评论列表和分页信息}', '', $temp);
			$temp = str_replace('$'.'{页面关键字生成}', $this->titleCreate($get), $temp);
			$temp = str_replace('$'.'{页面描述生成}', $this->descriptionCreate($get), $temp);
			$temp = str_replace('$'.'{页面title生成}', $this->titleCreate($get).' of '.$i, $temp);
			
			$temp = str_replace('$'.'{产品品牌}', $this->productBrand($get), $temp);
			$temp = str_replace('$'.'{产品名称}', $get['产品名称'],$temp);
			$temp = str_replace('$'.'{是否是Win产品（显示Win图片）}', $this->isShowImage($get), $temp);
			$temp = str_replace('$'.'{产品切换列表}', $this->switchPage($get), $temp);
			$temp = str_replace('$'.'{下载与免费上}', $this->downloadAndPriceTop($get), $temp);
			$temp = str_replace('$'.'{评论信息}', $this->reviews($get), $temp);
			$temp = str_replace('$'.'{写评论地址}', $this->reviewsWriteUrl($get), $temp);
			$temp = str_replace('$'.'{右侧bar}', $this->rightBar($get), $temp);
			$temp = str_replace('$'.'{右侧视频bar}', $this->rightVideoBar($get), $temp);
			$temp = str_replace('$'.'{右侧Comparison}', $this->rightComparison($get), $temp);
			$temp = str_replace('$'.'{右侧留言}', $this->rightWord($get), $temp);
			$temp = str_replace('$'.'{右侧Awards}', $this->rightAwards($get), $temp);
			$temp = str_replace('$'.'{右侧高版本产品}', $this->rightProduct($get), $temp);
			$temp = str_replace('$'.'{右侧tips}', $this->rightTips($get), $temp);
			$temp = str_replace('$'.'{右侧视频弹出html}', $this->rightVideoPopup($get), $temp);
			$temp = str_replace('$'.'{googleCode}', $this->googleCode($get),$temp);
			$temp = str_replace('$'.'{下侧下一页和下下页}', $this->nextPage($get), $temp);
			$temp = str_replace('$'.'{下载与免费下}', $this->downloadAndPriceBtn($get), $temp);
			$temp = str_replace('$'.'{关联产品}', $this->relProduct($get), $temp);
		
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
			
			$str_link  = '';
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == 1 ) {
			
				$str_link = '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i > 1 && $i < $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				
				$str_link .= '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == $max_page) {
				
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if ( ($i - 1) == 1 ) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			}
			
			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			}else{
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}
			
		}
				
		
	}
	/**
	* 返回产品页面固定栏 
	* @param   array      		 $get       字段数组
	* @return  string
	*/	
	function product_fixed($get){
	$id = (int) $get['产品ID'];
	$sql = "SELECT p.product_type 
		FROM won_product won_p 
		LEFT JOIN product p ON p.product_id = won_p.won_product_id 
		WHERE id = {$id} AND won_p.won_product_delete = 0  ";
	$product_type = $this->db->getOne($sql);
	if(!$product_type) return '';
	$downUrl = parent::productDownLoadUrl($get);
	$productNameOS = parent::productNameHadOs($get);
	if(strpos($productNameOS,'for Windows')){
		$os = 'win';
		$productNameOS = str_replace('for ' , 'para ' , $productNameOS) ;
	}
	else{
		$os = 'mac';
	}
	$switch = $this->switchPage($get);
	 $str='<div class="rollTop" style="display:none;" >
		<div class="wrap">
			<div class="name">
			 <strong>Wondershare '.$productNameOS.'</strong>
			 <div class="rollNav">'.$switch.'</div>
			  </span>
			</div>
			<div class="fr btn-'.$os.'">
				<a href="'.$downUrl.'" rel="nofollow" onClick="var that=this;_gaq.push([\'_trackEvent\', this.href, \'Download\', document.location.pathname]); _gaq.push([\'_trackPageview\', this.href]); setTimeout(function(){location.href=that.href;},100);return false;"  class="free fl"> <span class="dd">Versão: <script type="text/javascript" src="http://www.wondershare.com.br/interface/product/productInterface.php?id='.$id.'&info=version"></script></span></a>
			</div>
		</div>
	</div>';
		return $str;
	}

	
}
?>